<script type="text/javascript">
    $(document).ready(function() {
        $("#activity_checkAll").click(function() {
            if ($(this).attr("checked") == "checked") {
                $(":checkbox").attr("checked", true);
            } else {
                $(":checkbox").attr("checked", false);
            }
        });

    });
</script> 
<legend>
    <h4>
        <?php
        echo $control->getAjaxLink(array('name' => '功能列表', 'id' => 'showEventList'), array(
            'cooker' => 'BAEvent@showEventList'
        ));
        ?>\
        <?php
        echo $control->getAjaxLink(array('name' => '买单类型', 'id' => 'showBillTypeList'), array(
            'cooker' => 'BAWeBillCooker@showBillTypeList'
        ));
        ?>\
        <?php
        $billTypeAlias = $billType->getValue();
        echo $billTypeAlias;
        ?>
    </h4>
</legend>
<fieldset>
    <table class="table table-hover">
        <thead>
            <tr>
                <th><input type="checkbox" name="activity_checkAll" id="activity_checkAll"></th>
                <th>消费金额</th>
                <th>支付金额</th>
                <th>减扣元(分)</th>
                <th>买单时间</th>
                <th>客户姓名</th>
                <th>剩余积分</th>
                <th>操作</th>
            </tr> 
        </thead>
        <tbody>
            <?php
            foreach ($billView as $id => $list) {
                $title = '---';
                $deductedMoney = 0;
                $deductedMemberPoint = 0;
                $billAmount = $list->getItem('amount')->getValue();
                $billTime = $list->getItem('billTime')->getValue();
                $billTime = date("Y.m.d H:i", $billTime);
                $payAmount = $billAmount;
                $userPoint = '--';
                if ($list->getItem('deductedMoney')) {
                    $deductedMoney = $list->getItem('deductedMoney')->getValue();
                }
                if ($list->getItem('deductedMemberPoint')) {
                    $deductedMemberPoint = $list->getItem('deductedMemberPoint')->getValue();
                }
                if ($list->getItem('payAmount') != NULL) {
                    $payAmount = $list->getItem('payAmount')->getValue();
                }

                if ($list->getItem('memberPointAccountId') != NULL) {
                    $mpId = $list->getItem('memberPointAccountId')->getValue();
                    $memberPointAccountTable = new BASpaceSheet('memberPointAccount');
                    $mpAccount = $memberPointAccountTable->getListById($mpId);
                    $title = '';
                    if ($mpAccount->getItem('gender') != NULL) {
                        $gender = $mpAccount->getItem('gender')->getValue();
                        $title.=BAMemberPointCooker::getGenderAlias($gender) . '.';
                    }
                    if ($mpAccount->getItem('familyName') != NULL) {
                        $title.=$mpAccount->getItem('familyName')->getValue();
                    }
                    if ($mpAccount->getItem('surName') != NULL) {
                        $title.=$mpAccount->getItem('surName')->getValue();
                    }
                    $userPoint = $mpAccount->getItem('memberPoint')->getValue();
                }
                ?>
                <tr>
                    <td><label class="checkbox">
                            <input type="checkbox" name="subBox[]" value="<?php echo $id; ?>"> 
                        </label></td>
                    <td> <?php echo $billAmount; ?> </td>
                    <td> <?php echo $payAmount; ?> </td>
                    <td> <?php echo $deductedMoney . '(' . $deductedMemberPoint . ')' ?> </td>
                    <td> <?php echo $billTime; ?> </td>
                    <td> <?php echo $title; ?> </td>
                    <td> <?php echo $userPoint; ?> </td>
                    <td>
                        <div class="row-fluid">
                            <?php
                            echo $control->getAjaxLink(array('name' => '修改', 'id' => 'showAddBill'), array(
                                'cooker' => 'BAWeBill@showAddBill',
                                'billId' => $id
                            ));
                            ?>|
                            <?php
                            echo $control->getAjaxLink(array('name' => '删除', 'id' => 'deleteBill'), array(
                                'cooker' => 'BAWeBill@deleteBill',
                                'billId' => $id
                            ));
                            ?>
                        </div>                   
                    </td>
                </tr>
            <?php }
            ?>
        </tbody>
    </table>
    <div class="pagination">  
        <ul>  
            <li class="active">
                <a href="javascript:void()">前一页</a>    </li>  
            <li class="active">
                <a href="javascript:void()">1</a>    </li>  
            <li class="active">
                <a href="javascript:void()">后一页</a>    </li>  
        </ul>  
    </div>
    <div>
        <?php
        echo $control->getAjaxLink(array('name' => '添加买单', 'id' => 'showAddBill'), array(
            'cooker' => 'BAWeBill@showAddBill',
            'billId' => 0,
            'htmlOptions' => array('class' => 'btn')
        ));
        ?>
    </div>
